import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBApplication.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBProjectPopPage/YBZuZhiGuanLiQuanXianPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBMineModule/YBMineProvider/YBMineUserProvider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBNetWorkModule/YBAPi/YBAPi.dart';

class YBQiYeDisPlayInfoPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Container(
       child: Scaffold(
         appBar: AppBar(
           elevation: 0,
           title: Text(YBChineseText.mineQiYeInfoTitle,style: YBTextStyle.TextStyle30313320Medium),
           actions: [
             InkWell(
               child: Padding(
                 padding: EdgeInsets.only(right: YBTextStyle.adapterSize10),
                 child: Center(
                   child: Text(
                     YBChineseText.mineChongXinAuthInfoTitle,
                     style: YBTextStyle.TextStyleA9AEB812,
                   ),
                 ),
               ),
               onTap: (){
                 YBZuZhiGuanLiQuanXianPage.showQiYeAndPersonalLiApi(context);
               },
             ),
           ],
         ),
         body: ChangeNotifierProvider(
           create: (context) => YBMineUserProvider()..getUserInfoData(),
           child: Consumer<YBMineUserProvider>(
               builder:(context,dataUserInfo,child){
                 Widget containerWidget;
                 if (dataUserInfo.mineUserInfoModel.certStatus == -1){
                   containerWidget =  Container(
                     alignment: Alignment.centerLeft,
                     height: 26,
                     color: YBColor.colorE6A23C.withOpacity(0.2),
                     child: Padding(
                       padding: EdgeInsets.only(left: YBTextStyle.adapterSize20),
                       child: Text(YBChineseText.mineAuthInfoShengHeingTitle,
                         style:YBTextStyle.TextStyleE6A23C13,
                       ),
                     ),
                   );
                 }else if (dataUserInfo.mineUserInfoModel.certStatus == 1){
                   containerWidget =  Container(
                     alignment: Alignment.centerLeft,
                     height: YBTextStyle.adapterSize26,
                     color: YBColor.colorF56C6C.withOpacity(0.2),
                     child: Padding(
                       padding: EdgeInsets.only(left: YBTextStyle.adapterSize20),
                       child: Text(YBChineseText.mineAuthInfoBoHuiTitle,
                         style:YBTextStyle.TextStyleF56C6C13,
                       ),
                     ),
                   );
                 }else if (dataUserInfo.mineUserInfoModel.certStatus == 2){
                   containerWidget =  Container(
                     alignment: Alignment.centerLeft,
                     height: YBTextStyle.adapterSize26,
                     color: YBColor.color67C23A.withOpacity(0.2),
                     child: Padding(
                       padding: EdgeInsets.only(left: YBTextStyle.adapterSize20),
                       child: Text(YBChineseText.mineAuthInfoYiAuthTitle,
                         style:YBTextStyle.TextStyle67C23A13,
                       ),
                     ),
                   );
                 }


                 return SingleChildScrollView(
                   child: Column(
                     children: [
                       containerWidget,
                       Container(
                         height: YBTextStyle.adapterSize8,
                       ),
                       Container(
                         height: YBTextStyle.adapterSize58,
                         color: YBColor.white,
                         child: Padding(
                           padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                           child: Row(
                             children: [
                               Container(
                                 child: Text(
                                   YBChineseText.mineAuthTypeTitle,
                                   style: YBTextStyle.TextStyle2F303314,
                                 ),
                               ),
                               Expanded(
                                 child: Container(
                                   alignment: Alignment.centerRight,
                                   child: Text(
                                     YBChineseText.mineQiYeAuthTitle,
                                     style: YBTextStyle.TextStyle2F303314,
                                   ),
                                 ),
                               ),

                             ],
                           ),
                         ),
                       ),
                       Container(
                         height: YBTextStyle.adapterSize8,
                       ),
                       Container(
                         color: YBColor.white,
                         child: Padding(
                           padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                           child: Column(
                             children: [
                               Container(
                                 child: InkWell(
                                   child: getLoadInfo(YBChineseText.mineCompanyNameTitle, dataUserInfo.mineUserInfoModel.customerName??""),
                                   onTap: (){

                                   },
                                 ),
                               ),
                               Container(
                                 child: InkWell(
                                   child: getLoadInfo(YBChineseText.mineTongYiSheHuiXinYongDaiMaTitle, dataUserInfo.mineUserInfoModel.creditCode??""),
                                   onTap: (){

                                   },
                                 ),
                               ),
                               Container(
                                 child: InkWell(
                                   child: getLoadInfo(YBChineseText.mineFaDingDaiBiaoRenTitle, dataUserInfo.mineUserInfoModel.legalPerson??""),
                                   onTap: (){

                                   },
                                 ),
                               ),
                             ],
                           ),
                         ),
                       ),
                       Container(
                         height: YBTextStyle.adapterSize10,
                       ),
                       Container(
                         color: YBColor.white,
                         child: Row(
                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
                           crossAxisAlignment: CrossAxisAlignment.center,
                           children: [
                             Container(
                               width:  YBTextStyle.adapterSize20,
                             ),
                             Container(
                               child: Text(
                                 YBChineseText.mineYingYeZhiZhaoTitle,
                                 style: YBTextStyle.TextStyle2F303314,
                               ),
                             ),
                             Spacer(),
                             Container(
                               height: YBTextStyle.adapterSize90,
                               width: YBTextStyle.adapterSize90,
                               child: CachedNetworkImage(imageUrl:'${YBApi.Base_image_URL}/${dataUserInfo.mineUserInfoModel.certCredUrl}'),
                             ),
                             Container(
                               width: YBTextStyle.adapterSize20,
                             ),
                           ],
                         ),
                       ),
                       Container(
                         color: YBColor.white,
                         height: YBTextStyle.adapterSize10,
                       ),
                     ],
                   ),
                 );
               }
           ),
         ),
       ),
    );
  }

  Widget getLoadInfo(String title, String bodyTitle){
    return Container(
      height: YBTextStyle.adapterSize58,
      child: Row(
        children: [
          Container(
            child: Text(
              title,
              style: YBTextStyle.TextStyle2F303314,
            ),
          ),
          Expanded(
            child: Container(
              alignment: Alignment.centerRight,
              child: Text(
                bodyTitle,
                style: YBTextStyle.TextStyle2F303314,
              ),
            ),
          ),
        ],
      ),
    );
  }

}
